package com.hgkj.cloud.base.service.impl;

import com.hgkj.cloud.base.common.PageInfo;
import com.hgkj.cloud.base.dao.TenantLogsMapper;
import com.hgkj.cloud.base.domain.TenantLogs;
import com.hgkj.cloud.base.service.TenantLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TenantLogsServiceImpl implements TenantLogsService {

    @Autowired
    private TenantLogsMapper tenantLogsMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return tenantLogsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TenantLogs record) {
        return tenantLogsMapper.insert(record);
    }

    @Override
    public int insertSelective(TenantLogs record) {
        return tenantLogsMapper.insertSelective(record);
    }

    @Override
    public TenantLogs selectByPrimaryKey(Long id) {
        return tenantLogsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TenantLogs record) {
        return tenantLogsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TenantLogs record) {
        return tenantLogsMapper.updateByPrimaryKey(record);
    }

    @Override
    public Long findAllLogCount(Map<String, Object> map) {
        return tenantLogsMapper.findAllLogCount(map);
    }

    @Override
    public List<TenantLogs> listLogs(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return tenantLogsMapper.listLogs(map);
    }

    public int insertLog(String user_uuid,Long framework_id,String module,String operation) {
        TenantLogs log = new TenantLogs();
        log.setFramework_id(framework_id);
        log.setUser_uuid(user_uuid);
        log.setModule(module);
        log.setOperation(operation);
        return tenantLogsMapper.insertLog(log);
    }


}
